package com.bh.web.controller.ledger;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.bh.common.utils.SecurityUtils;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bh.common.annotation.Log;
import com.bh.common.core.controller.BaseController;
import com.bh.common.core.domain.AjaxResult;
import com.bh.common.enums.BusinessType;
import com.bh.ledger.domain.JcOtherFee;
import com.bh.ledger.service.IJcOtherFeeService;
import com.bh.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import com.bh.common.core.page.TableDataInfo;

/**
 * 场站其他费用Controller
 * 
 * @author slx
 * @date 2024-03-12
 */
@RestController
@RequestMapping("/ledger/otherFee")
public class JcOtherFeeController extends BaseController
{
    @Autowired
    private IJcOtherFeeService jcOtherFeeService;

    /**
     * 查询场站其他费用列表
     */
    @ApiOperation("查询场站其他费用列表")
    @PreAuthorize("@ss.hasPermi('ledger:otherFee:list')")
    @GetMapping("/list")
    public TableDataInfo list(JcOtherFee jcOtherFee)
    {
        startPage();
        List<JcOtherFee> list = jcOtherFeeService.selectJcOtherFeeList(jcOtherFee);
        return getDataTable(list);
    }

    /**
     * 导出场站其他费用列表
     */
    @PreAuthorize("@ss.hasPermi('ledger:otherFee:export')")
    @Log(title = "场站其他费用", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JcOtherFee jcOtherFee)
    {
        List<JcOtherFee> list = jcOtherFeeService.selectJcOtherFeeList(jcOtherFee);
        ExcelUtil<JcOtherFee> util = new ExcelUtil<JcOtherFee>(JcOtherFee.class);
        util.exportExcel(response, list, "场站其他费用数据");
    }

    /**
     * 获取场站其他费用详细信息
     */
    @ApiOperation("获取场站其他费用详细信息")
    @PreAuthorize("@ss.hasPermi('ledger:otherFee:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(jcOtherFeeService.selectJcOtherFeeById(id));
    }

    /**
     * 新增场站其他费用
     */
    @ApiOperation("新增场站其他费用")
    @PreAuthorize("@ss.hasPermi('ledger:otherFee:add')")
    @Log(title = "场站其他费用", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JcOtherFee jcOtherFee)
    {
        if (jcOtherFee.getJcOrganizationId() == null) {
            jcOtherFee.setJcOrganizationId(getOrgId());
        }
        return toAjax(jcOtherFeeService.insertJcOtherFee(jcOtherFee));
    }

    /**
     * 修改场站其他费用
     */
    @ApiOperation("修改场站其他费用")
    @PreAuthorize("@ss.hasPermi('ledger:otherFee:edit')")
    @Log(title = "场站其他费用", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JcOtherFee jcOtherFee)
    {
        if (jcOtherFee.getJcOrganizationId() == null) {
            jcOtherFee.setJcOrganizationId(getOrgId());
        }
        return toAjax(jcOtherFeeService.updateJcOtherFee(jcOtherFee));
    }

    /**
     * 删除场站其他费用
     */
    @ApiOperation("删除场站其他费用")
    @PreAuthorize("@ss.hasPermi('ledger:otherFee:remove')")
    @Log(title = "场站其他费用", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(jcOtherFeeService.deleteJcOtherFeeByIds(ids));
    }
}
